/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ua.lviv.franko.integration;

/**
 * 
 * @author mark
 */
public class Func2D implements IFunction2D {

	public int	i;

	public int	j;

	public double calculate(double x, double y) {
		double res = 0;
		switch (i) {
			case 1:
				res = x * (2 * x - 1);
				break;
			case 2:
				res = 4 * x * y;
				break;
			case 3:
				res = y * (2 * y - 1);
				break;
			case 4:
				res = 4 * x * (1 - x - y);
				break;
			case 5:
				double l = 1 - x - y;
				res = l * (2 * l - 1);
				break;
			case 6:
				res = 4 * (1 - x - y) * x;
				break;
			default:
				return 0.0;
		}
		switch (j) {
			case 1:
				res *= x * (2 * x - 1);
				break;
			case 2:
				res *= 4 * x * y;
				break;
			case 3:
				res *= y * (2 * y - 1);
				break;
			case 4:
				res *= 4 * x * (1 - x - y);
				break;
			case 5:
				double l = 1 - x - y;
				res *= l * (2 * l - 1);
				break;
			case 6:
				res *= 4 * (1 - x - y) * x;
				break;
			default:
				return 0.0;
		}
		return res;
	}

	public double calculateDerivatyX(double x, double y) {
		throw new UnsupportedOperationException("Not supported yet.");
	}
	public double calculateDerivatyY(double x, double y) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

}
